package de.gameduell.framework.facebook.app {
	import de.gameduell.framework.util.Library;

	import flash.display.Bitmap;
	import flash.display.MovieClip;

	/**
	 * @author meue
	 */
	public class Placeholder {
		private static var library:Library;
		public var libname:String;
		public var clip:MovieClip;
		public var placeholder:MovieClip;

		public function Placeholder(aLibname:String) {
			libname = aLibname;
			if(library == null) {
				library = Library.getInstance();
			}
		}

		public function getClip():MovieClip {
			clip = new MovieClip();
			// loader einsetzen
			clip.addChild(new Bitmap(library.createBitmapData("brick_select_1.png", 90, 60)));
			return clip;
		}

		public function reload():void {
			
			// add lib-image to placeholder
			try {
				var mc:MovieClip = library.createClip(libname);
			}catch(error:Error) {
				return;
			}
			// remove loader from placeholder
			for(var i:int = 0;i < clip.numChildren;i++) {
				try {
					clip.removeChildAt(i);
				}catch(error:Error) {
				}
			}
			clip.addChild(mc);
		} 
	}
}
